package com.longge;

import java.util.Arrays;
import java.util.stream.LongStream;
import java.util.stream.Stream;

/**
 * @创建人 xinglongge
 * @创建时间 2021/7/20
 * @描述
 */
public class MaxPoints {
    public long maxPolongs(int[][] points) {
        long[] dp = Arrays.stream(points[0]).mapToLong(a -> a).toArray();
        for (int i = 1; i < points.length; i++) {
            long[] temp = new long[points[i].length];
            long lmax = 0;
            for (int j = 0; j < points[i].length; j++) {
                lmax = Math.max(lmax - 1, dp[j]);
                temp[j] = lmax + points[i][j];
            }
            long rmax = 0;
            for (int j = points[i].length - 1; j >= 0; j--) {
                rmax = Math.max(rmax - 1, dp[j]);
                temp[j] = Math.max(rmax + points[i][j], temp[j]);
            }
            dp = temp;
        }
        return LongStream.of(dp).max().getAsLong();
    }

    public static void main(String[] args) {
        String[] a = {"abc", "abcde", "abcd"};
        Arrays.sort(a);
        Arrays.stream(a).forEach(System.out::println);
    }
}
